(function($, doc, chat) {

	var settings = app.getSettings();
	var state = app.getState();
	var uid = state.user_id;

	//console.log(uid);
	//localStorage.removeItem('mainlist' + uid);
	window.addEventListener('refreshList', function(e) {
		//var chatdata = JSON.parse(localStorage.getItem('mainlist' + uid) || '[]');
		chat.renderlist('room');
		//document.getElementById('indexHeader').innerHTML = 'Hello World';  
	})
	

	$.plusReady(function() {
		mui.init({
			gestureConfig: {
				tap: true, //默认为true
				doubletap: true, //默认为false
				longtap: true, //默认为false
				swipe: true, //默认为true
				drag: true, //默认为true
				hold: true, //默认为false，不监听
				release: true //默认为false，不监听
			},
			/*preloadPages: [{
				url: 'contact.html',
				id: 'contact.html'
			}, {
				url: 'find.html',
				id: 'find.html'
			}, {
				url: 'me.html',
				id: 'me.html'
			}]*/

		});
		//var chatdata = chat.get();
		chat.renderlist('room');
		var mainid = localStorage.getItem('mainpage');
		var mainWin = plus.webview.getWebviewById(mainid);
		doc.addEventListener('swipeleft', function(event) {
			var angle = event.detail.angle;
			angle = Math.abs(angle);
			if(angle > 165 && angle < 195) {
			mui.fire(mainWin, 'swipe_event', {
				target: 'contact.html'
			});
			}
		});
		doc.addEventListener('swiperight', function(event) {
			if(Math.abs(event.detail.angle) < 30) {
			mui.fire(mainWin, 'swipe_event', {
				target: 'chat.html'
			});
			}
		});
		
		/*
		doc.addEventListener('swipeleft', function() {
			//location.href = 'contact.html';
			plus.webview.hide('chat.html');
			plus.webview.show('room.html', "slide-in-right", 300);
		});*/
	});

}(mui, document, chat));